package com.ksyun.cloudhostalarmprocessing.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常处理器
 */
@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(value = MyException.class)
    public Response handlePathException(MyException e){
        e.printStackTrace();
        return Response.error(CodeEnum.UNIFIED_ERROR_RETURN.getCode(), CodeEnum.UNIFIED_ERROR_RETURN.getMsg());
    }

    @ExceptionHandler
    public Response HandleException(Exception e){
        e.printStackTrace();
        return Response.error(CodeEnum.UNIFIED_ERROR_RETURN.getCode(), CodeEnum.UNIFIED_ERROR_RETURN.getMsg());
    }
}
